import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import BusinessList from '../views/BusinessList'
import BusinessInfo from '../views/BusinessInfo'
import Login from '../views/Login'
import Register from '../views/Register'
import AddUserAddress from '../views/AddUserAddress'
import UserAddress from '../views/UserAddress'
import EditUserAddress from '../views/EditUserAddress'
import Order from '../views/Order'
import Payment from '../views/Payment'
import OrderList from '../views/OrderList'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },{
    path: '/home',
    name: 'Home',
    component: Home
  },{
    path: '/businesslist',
    name: 'BusinessList',
    component: BusinessList
  },{
    path: '/businessinfo',
    name: 'BusinessInfo',
    component: BusinessInfo
  },{
    path: '/login',
    name: 'Login',
    component: Login
  },{
    path: '/register',
    name: 'Register',
    component: Register
  },{
    path: '/order',
    name: 'Order',
    component: Order
  },{
    path: '/addUseraddress',
    name: 'AddUserAddress',
    component: AddUserAddress
  },{
    path: '/useraddress',
    name: 'UserAddress',
    component: UserAddress
  },{
    path: '/editUseraddress',
    name: 'EditUserAddress',
    component: EditUserAddress
  },{
    path: '/payment',
    name: 'Payment',
    component: Payment
  },{
    path: '/orderlist',
    name: 'OrderList',
    component: OrderList
  },
]

//解决重复路由报异常问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
